<?php
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Common/Helpers/Constants.php");

require_once("/home/bluecbhv/Jcuhelpers-WebTech/Common/Algorithms/Content_Scraper.php");
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Common/Algorithms/JSON_Decoder.php");
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Google_Custom_Search/Algorithms/Decoded_JSON_Data_Filter.php");
require_once("/home/bluecbhv/Jcuhelpers-WebTech/Common/Algorithms/New_JSON_File_Creation.php");

/***********************************************
	This class would create a list of Google
	custom search results related to the
	keyword "Web Design Trends".
************************************************/
class GoogleCustomSearch {
	private $scrapedContent_1 = NULL;
	private $scrapedContent_2 = NULL;
	private $scrapedContent_3 = NULL;
	
	private $decodedJSONData_1 = NULL;
	private $decodedJSONData_2 = NULL;
	private $decodedJSONData_3 = NULL;
	
	private $jsonDataToBeSaved = NULL;
	private $newJSONFile = NULL;
	
	/************************************************************/
	
	function __construct() {
		$csObj_1 = new ContentScraper();
		$this->scrapedContent_1 = $csObj_1->scrapeContent(GOOGLE_CS_API_URL);
		
		$csObj_2 = new ContentScraper();
		$this->scrapedContent_2 = $csObj_2->scrapeContent(GOOGLE_CS_API_URL."&start=11");
		
		$csObj_3 = new ContentScraper();
		$this->scrapedContent_3 = $csObj_3->scrapeContent(GOOGLE_CS_API_URL."&start=21");
		
		$jdObj_1 = new JSONDecoder();
		$this->decodedJSONData_1 = $jdObj_1->decodeJSONData($this->scrapedContent_1);
		
		$jdObj_2 = new JSONDecoder();
		$this->decodedJSONData_2 = $jdObj_2->decodeJSONData($this->scrapedContent_2);
		
		$jdObj_3 = new JSONDecoder();
		$this->decodedJSONData_3 = $jdObj_3->decodeJSONData($this->scrapedContent_3);
				
		$djdfObj = new DecodedJSONDataFilter();
		$this->jsonDataToBeSaved = $djdfObj->filterDecodedJSONData($this->decodedJSONData_1,
																	$this->decodedJSONData_2,
																	$this->decodedJSONData_3
																);
		
		$this->newJSONFile = new NewJSONFileCreation($this->jsonDataToBeSaved, SEARCH_RESULTS_FILEPATH);
	}
}
?>